package io.adrainty.bolee.file.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.adrainty.bolee.file.models.entity.FileEntity;
import io.adrainty.bolee.file.service.IFileService;
import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>FileBusinessController</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description 附件展示维护controller
 * @since 2025/8/18 15:30:09
 */

@Tag(name = "附件展示维护controller")
@RestController
@RequestMapping("file")
public class FileBusinessController {

    @Resource
    private IFileService fileService;

    @PutMapping(value = "replace-bind-batch-file")
    @Operation(summary = "批量替换绑定文件")
    public ResultDTO<Boolean> replaceBindBatchFile(@RequestBody List<FileEntity> fileVOs) {
        Boolean flag = fileService.replaceBindBatchFile(fileVOs);
        return ResultDTOUtil.success(flag);
    }

    @PostMapping("/page/{pageNum}/{pageSize}")
    @Operation(summary = "分页查询")
    public ResultDTO<IPage<FileEntity>> page(@PathVariable("pageNum") Integer pageNum,
                                             @PathVariable("pageSize") Integer pageSize,
                                             @RequestBody FileEntity param) {
        IPage<FileEntity> fileVOs = fileService.pageFile(pageNum, pageSize, param);
        return ResultDTOUtil.success(fileVOs);
    }

}
